<?php

require_once dirname(__FILE__) . '/autoload.php';
require_once dirname(__FILE__) . '/vpslist.config.php';

$TotalCount = count($arrVpsData);
$WarningCount = 0;

$HTMLBODY = '';
$HTMLBODY.= '<b>VPS过期时间统计(' . $TotalCount . '个)：</b></div>
          <table border="1" width="100%" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0" style="border-collapse: collapse;font-size: 14px;">';
$HTMLBODY.='<tr height="35">
    <td width="100">VPS-IP&nbsp;</td>
    <td width="150">VPS别名&nbsp;</td>
    <td width="150">服务提供商&nbsp;</td>
    <td width="100">过期时间&nbsp;</td>
    <td width="100">用户名</td>
    <td width="100">距离过期时间</td></tr>
    ';


foreach ($arrVpsData as $ip => $vps) {
    $arrDateTime = $vps['exp'];
    //距离过期时间
    $time = strtotime($arrDateTime) - time();
    $days = floor($time / 86400);
    if ($days <= 90) {
        $color = ' color="red" ';
        $WarningCount++;
    } else {
        $color = '';
    }

    $HTMLBODY.='<tr height="35">
    <td width="100"><font' . $color . '>' . $ip . '</font></td>
    <td width="150">' . $vps['idc'] . '</td>
    <td width="150">' . $vps['alias'] . '</td>
    <td width="100"><font' . $color . '>' . $vps['exp'] . '</font></td>
    <td width="100">' . $vps['username'] . '</td>
    <td width="100"><font' . $color . '>' . $days . '</font>&nbsp;天</td></tr>
    ';
}

$HTMLBODY.='</table>';

$HTMLBODY.='<hr />';

$arrUsers = array(
    'think889977@sina.com',
);

post_email_api('[警告:' . $WarningCount . ']每日VPS过期检测报告[' . date('Y-m-d H:i:s') . ']', $HTMLBODY, $arrUsers);



?>